package com.hut.oa.model.bean;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonIgnore;
/**
 * 考勤管理
 * @author 潘寻毅
 *
 */
@Entity
@Table(name="work_attend")
public class WorkAttend {
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="wa_id")
	private Long id;//考勤id
	
	@Column(name="wa_type",nullable=false)
	private String type;//考勤类型
	
	@Column(name="wa_time",nullable=false)
	private Date time=new Date();//打卡时间
	
	@Column(name="wa_ip",nullable=false)
	private String ip;//登录ip
	
	@Column(name="Wa_remark")
	private String remark="无申诉";//备注
	
	@Column(name="wa_status",nullable=false)
	private Integer status;//上班状态
	
	/*@Column(name="u_id",nullable=false)
	private Long userId;//用户id
*/	
	@JoinColumn(name = "u_id")
	@ManyToOne(cascade=CascadeType.REFRESH,fetch = FetchType.EAGER)
	private User user;//打卡用户
	
	@JsonIgnore
	@OneToOne(mappedBy = "workattend")
	private AttendComplaint ac;//申诉记录
	
	public WorkAttend() {
		super();
	}
	
	public WorkAttend(String type, Date time, String ip, Integer status, User user) {
		super();
		this.type = type;
		this.time = time;
		this.ip = ip;
		this.status = status;
		this.user = user;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public Date getTime() {
		return time;
	}

	public void setTime(Date time) {
		this.time = time;
	}

	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	/*public Long getUserId() {
		return userId;
	}

	public void setUserId(Long userId) {
		this.userId = userId;
	}*/
	
	public AttendComplaint getAc() {
		return ac;
	}

	public void setAc(AttendComplaint ac) {
		this.ac = ac;
	}
	
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@Override
	public String toString() {
		return "WorkAttend [id=" + id + ", type=" + type + ", time=" + time + ", ip=" + ip + ", remark=" + remark
				+ ", status=" + status + "]";
	}
	
	
}
